package cn.iocoder.yudao.module.enterprise.dal.mysql.emissionsource;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.enterprise.controller.admin.emissionsource.vo.EmissionSourceExportReqVO;
import cn.iocoder.yudao.module.enterprise.controller.admin.emissionsource.vo.EmissionSourcePageReqVO;
import cn.iocoder.yudao.module.enterprise.dal.dataobject.emissionsource.EmissionSourceDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 排放源 Mapper
 *
 * @author StevenShen
 */
@Mapper
public interface EmissionSourceMapper extends BaseMapperX<EmissionSourceDO> {

    default PageResult<EmissionSourceDO> selectPage(EmissionSourcePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EmissionSourceDO>()
                .likeIfPresent(EmissionSourceDO::getName, reqVO.getName())
                .eqIfPresent(EmissionSourceDO::getFacility, reqVO.getFacility())
                .eqIfPresent(EmissionSourceDO::getGhgClassification, reqVO.getGhgClassification())
                .eqIfPresent(EmissionSourceDO::getIsoClassification, reqVO.getIsoClassification())
                .orderByDesc(EmissionSourceDO::getId));
    }

    default List<EmissionSourceDO> selectList(EmissionSourceExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<EmissionSourceDO>()
                .eqIfPresent(EmissionSourceDO::getGhgClassification, reqVO.getGhgClassification())
                .eqIfPresent(EmissionSourceDO::getGhgCategory, reqVO.getGhgCategory())
                .eqIfPresent(EmissionSourceDO::getIsoClassification, reqVO.getIsoClassification())
                .eqIfPresent(EmissionSourceDO::getIsoCategory, reqVO.getIsoCategory())
                .orderByDesc(EmissionSourceDO::getId));
    }

}
